﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToRTR.CApExportToRTRStatusManager
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Collections.Generic;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToRTR{

internal class CApExportToRTRStatusManager
{
  private CApExportToRTRStatusObjectIssueDataContainer[] m_issueDataContainers = new CApExportToRTRStatusObjectIssueDataContainer[26]
  {
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Warning),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Error),
    new CApExportToRTRStatusObjectIssueDataContainer(CApExportToRTRStatusManager.Severity.Ok)
  };
  private CApExportToRTRStatusManager.CApExportToRTRStatusSevirityCounter m_severityCount = new CApExportToRTRStatusManager.CApExportToRTRStatusSevirityCounter();
  private Dictionary<ITxObject, List<CApExportToRTRStatusManager.IssueType>> m_objectToIssueTypes = new Dictionary<ITxObject, List<CApExportToRTRStatusManager.IssueType>>();
  private Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData> m_scopeToScopeData = new Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData>();
  private Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, CApExportToRTRStatusManager.IApExportToRTRIssueObject> m_objToScopeMap = new Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, CApExportToRTRStatusManager.IApExportToRTRIssueObject>();
  private bool m_isModified;

  internal bool IsModified
  {
    get
    {
      bool isModified = this.m_isModified;
      this.m_isModified = false;
      return isModified;
    }
    private set => this.m_isModified = value;
  }

  internal CApExportToRTRStatusManager.Severity CurrentSeverity
  {
    get => this.m_severityCount.WorstSeverity;
  }

  internal CApExportToRTRStatusManager()
  {
  }

  internal CApExportToRTRStatusManager.Severity ComputeSeverityForObject(ITxObject obj)
  {
    CApExportToRTRStatusManager.Severity severity1 = CApExportToRTRStatusManager.Severity.Ok;
    List<CApExportToRTRStatusManager.IssueType> issueTypeList;
    if (this.m_objectToIssueTypes.TryGetValue(obj, out issueTypeList))
    {
      foreach (int index in issueTypeList)
      {
        CApExportToRTRStatusManager.Severity severityForObject = this.m_issueDataContainers[index].ComputeSeverityForObject(obj);
        if (severityForObject < severity1)
          severity1 = severityForObject;
      }
    }
    CApExportToRTRStatusManager.Severity severity2 = CApExportToRTRStatusManager.Severity.Ok;
    CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData sevirityScopeData;
    if (this.m_scopeToScopeData.TryGetValue((CApExportToRTRStatusManager.IApExportToRTRIssueObject) new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj), out sevirityScopeData))
      severity2 = sevirityScopeData.CurrentSeverity;
    return severity1 > severity2 ? severity2 : severity1;
  }

  internal CApExportToRTRStatusManager.Severity ComputeSeverityForIssue(
    CApExportToRTRStatusManager.IssueType issueType)
  {
    return this.m_issueDataContainers[(int) issueType].IssueSeverity;
  }

  internal void AddIssue(
    CApExportToRTRStatusManager.IssueType issueType,
    ITxObject obj,
    TxObjectList objects = null)
  {
    ITxObject scope = (ITxObject) null;
    this.AddIssueWithScope(issueType, obj, scope, objects);
  }

  internal void AddIssueWithScope(
    CApExportToRTRStatusManager.IssueType issueType,
    ITxObject obj,
    ITxObject scope,
    TxObjectList objects = null)
  {
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel scope1 = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(scope);
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel issueObjectModel = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj);
    this.AddIssueWithScope(issueType, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) issueObjectModel, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) scope1, objects);
  }

  internal void AddIssueWithScope(
    CApExportToRTRStatusManager.IssueType issueType,
    string category,
    string scope)
  {
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectString scope1 = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectString(scope);
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectString issueObjectString = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectString(category);
    this.AddIssueWithScope(issueType, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) issueObjectString, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) scope1);
  }

  private void AddIssueWithScope(
    CApExportToRTRStatusManager.IssueType issueType,
    CApExportToRTRStatusManager.IApExportToRTRIssueObject obj,
    CApExportToRTRStatusManager.IApExportToRTRIssueObject scope,
    TxObjectList objects = null)
  {
    ITxObject scope1 = (obj as CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel)?.Scope;
    if (issueType >= CApExportToRTRStatusManager.IssueType.NoIssue || !this.m_issueDataContainers[(int) issueType].AddIssueForObjects(scope1, objects))
      return;
    if (scope1 != null)
      this.AddIssueToObject(scope1, issueType);
    CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData scopeData = (CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData) null;
    if (scope != null)
    {
      if (!this.m_scopeToScopeData.TryGetValue(scope, out scopeData))
      {
        scopeData = new CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData();
        this.m_scopeToScopeData.Add(scope, scopeData);
      }
      if (!this.m_objToScopeMap.ContainsKey(obj))
        this.m_objToScopeMap.Add(obj, scope);
    }
    this.UpdateSeverity(obj, issueType, scopeData);
  }

  internal void AddIssue(CApExportToRTRStatusManager.IssueType issueType)
  {
    this.AddIssue(issueType, (ITxObject) null);
  }

  internal void RemoveIssue(CApExportToRTRStatusManager.IssueType issueType, string category)
  {
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectString issueObjectString = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectString(category);
    this.RemoveIssue(issueType, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) issueObjectString);
  }

  internal void RemoveIssue(CApExportToRTRStatusManager.IssueType issueType, ITxObject obj)
  {
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel issueObjectModel = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj);
    this.RemoveIssue(issueType, (CApExportToRTRStatusManager.IApExportToRTRIssueObject) issueObjectModel);
  }

  private void RemoveIssue(
    CApExportToRTRStatusManager.IssueType issueType,
    CApExportToRTRStatusManager.IApExportToRTRIssueObject obj)
  {
    ITxObject scope = (obj as CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel)?.Scope;
    if (issueType >= CApExportToRTRStatusManager.IssueType.NoIssue || !this.m_issueDataContainers[(int) issueType].RemoveIssueForObject(scope))
      return;
    this.DecrementSeverityCount(issueType);
    CApExportToRTRStatusManager.IApExportToRTRIssueObject key;
    CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData sevirityScopeData;
    if (obj == null || !this.m_objToScopeMap.TryGetValue(obj, out key) || !this.m_scopeToScopeData.TryGetValue(key, out sevirityScopeData))
      return;
    sevirityScopeData.RemoveIssueForObjOfScope(obj, issueType, this.m_issueDataContainers[(int) issueType].IssueSeverity);
    if (!sevirityScopeData.IsObjOfScope(scope))
      this.m_objToScopeMap.Remove(obj);
    if (!sevirityScopeData.IsEmptyScope())
      return;
    this.m_scopeToScopeData.Remove(key);
  }

  internal void RemoveIssue(CApExportToRTRStatusManager.IssueType issueType)
  {
    ITxObject itxObject = (ITxObject) null;
    this.RemoveIssue(issueType, itxObject);
  }

  internal void RemoveObjectFromIssues(ITxObject obj)
  {
    List<CApExportToRTRStatusManager.IssueType> issueTypeList = new List<CApExportToRTRStatusManager.IssueType>();
    List<CApExportToRTRStatusManager.IssueType> collection;
    if (this.m_objectToIssueTypes.TryGetValue(obj, out collection))
      issueTypeList.AddRange((IEnumerable<CApExportToRTRStatusManager.IssueType>) collection);
    foreach (CApExportToRTRStatusManager.IssueType issueType in issueTypeList)
      this.RemoveIssue(issueType, obj);
    if (obj == null)
      return;
    this.m_objectToIssueTypes.Remove(obj);
  }

  internal void Publish(CApExportToRTRStatusIssueBuilder builder)
  {
    bool flag = false;
    foreach (CApExportToRTRStatusManager.IssueType type in Enum.GetValues(typeof (CApExportToRTRStatusManager.IssueType)))
    {
      if (type < CApExportToRTRStatusManager.IssueType.NoIssue)
      {
        CApExportToRTRStatusObjectIssueDataContainer issueDataContainer = this.m_issueDataContainers[(int) type];
        if (issueDataContainer.ComputeSeverity() != CApExportToRTRStatusManager.Severity.Ok)
        {
          if (flag)
            builder.PreAppendNextObjectList();
          else
            flag = true;
          builder.Append(type, issueDataContainer);
        }
      }
    }
  }

  internal void PublishForObject(ITxObject obj, CApExportToRTRStatusIssueBuilder builder)
  {
    List<CApExportToRTRStatusManager.IssueType> issueTypeList;
    if (this.m_objectToIssueTypes.TryGetValue(obj, out issueTypeList))
    {
      bool flag = false;
      foreach (CApExportToRTRStatusManager.IssueType index in issueTypeList)
      {
        this.ComputeSeverityForIssue(index);
        if (flag)
          builder.PreAppendNextObjectList();
        else
          flag = true;
        builder.AppendTitle(index, this.m_issueDataContainers[(int) index].IssueSeverity);
      }
    }
    this.PublishForScope((CApExportToRTRStatusManager.IApExportToRTRIssueObject) new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj), builder);
  }

  internal void PublishForScope(string scope, CApExportToRTRStatusIssueBuilder builder)
  {
    this.PublishForScope((CApExportToRTRStatusManager.IApExportToRTRIssueObject) new CApExportToRTRStatusManager.CApExportToRTRIssueObjectString(scope), builder);
  }

  private void PublishForScope(
    CApExportToRTRStatusManager.IApExportToRTRIssueObject scopeObj,
    CApExportToRTRStatusIssueBuilder builder)
  {
    CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData sevirityScopeData;
    if (!this.m_scopeToScopeData.TryGetValue(scopeObj, out sevirityScopeData))
      return;
    CApExportToRTRStatusIssueBuilder scopeBuilder = builder.ScopeBuilder;
    bool flag = false;
    foreach (KeyValuePair<CApExportToRTRStatusManager.IssueType, int> toNumberOfObject in sevirityScopeData.IssueTypeToNumberOfObjects)
    {
      CApExportToRTRStatusManager.IssueType key = toNumberOfObject.Key;
      CApExportToRTRStatusManager.Severity severityForIssue = this.ComputeSeverityForIssue(key);
      if (flag)
        builder.PreAppendNextObjectList();
      else
        flag = true;
      scopeBuilder.AppendTitle(key, severityForIssue, toNumberOfObject.Value.ToString());
    }
  }

  internal bool ObjectHasIssues(ITxObject obj)
  {
    CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel key = new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj);
    return this.m_objectToIssueTypes.ContainsKey(obj) || this.m_scopeToScopeData.ContainsKey((CApExportToRTRStatusManager.IApExportToRTRIssueObject) key);
  }

  private void UpdateSeverity(
    CApExportToRTRStatusManager.IApExportToRTRIssueObject obj,
    CApExportToRTRStatusManager.IssueType issueType,
    CApExportToRTRStatusManager.CApExportToRTRStatusSevirityScopeData scopeData)
  {
    CApExportToRTRStatusManager.Severity issueSeverity = this.m_issueDataContainers[(int) issueType].IssueSeverity;
    this.IncreseSeverityCount(issueSeverity);
    scopeData?.AddIssueForObjOfScope(obj, issueType, issueSeverity);
  }

  private void IncreseSeverityCount(CApExportToRTRStatusManager.Severity severity)
  {
    this.m_severityCount.IncrementSeverity(severity);
    this.IsModified = true;
  }

  private void DecrementSeverityCount(CApExportToRTRStatusManager.IssueType issueType)
  {
    this.m_severityCount.DecrementSeverity(this.m_issueDataContainers[(int) issueType].IssueSeverity);
    this.IsModified = true;
  }

  private void AddIssueToObject(ITxObject obj, CApExportToRTRStatusManager.IssueType issueType)
  {
    if (obj == null)
      return;
    List<CApExportToRTRStatusManager.IssueType> issueTypeList;
    if (!this.m_objectToIssueTypes.TryGetValue(obj, out issueTypeList))
    {
      issueTypeList = new List<CApExportToRTRStatusManager.IssueType>();
      this.m_objectToIssueTypes.Add(obj, issueTypeList);
    }
    issueTypeList.Add(issueType);
  }

  internal enum IssueType
  {
    RestApiAccess,
    CouldNotAccessMachine,
    NoIP,
    NoPackageName,
    PackageNameExist,
    PackageNameCharacters,
    NoVisibleObjects,
    LocationNotReachable,
    LocationNoConfigurationFor,
    LocationWithCollision,
    GunWithLoops,
    NonValidKinematics,
    GunWithNoLimits,
    GunWithCompensationJoint,
    GunWithUnsupportedExternal,
    ExternalToolMonolithic,
    OperationNoLocations,
    NoSimulatedRobot,
    RobotNotVisible,
    Robot7Axis,
    NoActiveCollisionSets,
    NoCollisionSetForRobot,
    DeviceBlanked,
    SubDevicesBlanked,
    NoAvailableProjectSlots,
    NoIssue,
  }

  internal enum Severity
  {
    Error,
    Warning,
    Ok,
  }

  private class CApExportToRTRStatusSevirityCounter
  {
    private int[] m_severityCount = new int[3];

    internal int CountForSeverity(CApExportToRTRStatusManager.Severity severity)
    {
      return this.m_severityCount[(int) severity];
    }

    internal void IncrementSeverity(CApExportToRTRStatusManager.Severity severity)
    {
      ++this.m_severityCount[(int) severity];
    }

    internal void DecrementSeverity(CApExportToRTRStatusManager.Severity severity)
    {
      --this.m_severityCount[(int) severity];
    }

    internal CApExportToRTRStatusManager.Severity WorstSeverity
    {
      get
      {
        CApExportToRTRStatusManager.Severity worstSeverity = CApExportToRTRStatusManager.Severity.Ok;
        foreach (CApExportToRTRStatusManager.Severity index in Enum.GetValues(typeof (CApExportToRTRStatusManager.Severity)))
        {
          if (this.m_severityCount[(int) index] > 0)
          {
            worstSeverity = index;
            break;
          }
        }
        return worstSeverity;
      }
    }
  }

  private interface IApExportToRTRIssueObject : 
    IEquatable<CApExportToRTRStatusManager.IApExportToRTRIssueObject>
  {
  }

  private class CApExportToRTRIssueObjectString : 
    CApExportToRTRStatusManager.IApExportToRTRIssueObject,
    IEquatable<CApExportToRTRStatusManager.IApExportToRTRIssueObject>,
    IEquatable<CApExportToRTRStatusManager.CApExportToRTRIssueObjectString>
  {
    internal CApExportToRTRIssueObjectString(string scope) => this.Scope = scope;

    internal string Scope { get; } = string.Empty;

    public bool Equals(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString other)
    {
      return (object) other != null && this.Scope == other.Scope;
    }

    public override bool Equals(object obj)
    {
      bool flag = false;
      if (obj != null)
      {
        if (obj is string str)
        {
          flag = this.Scope == str;
        }
        else
        {
          CApExportToRTRStatusManager.CApExportToRTRIssueObjectString other = obj as CApExportToRTRStatusManager.CApExportToRTRIssueObjectString;
          if (other != (CApExportToRTRStatusManager.CApExportToRTRIssueObjectString) null)
            flag = this.Equals(other);
        }
      }
      else
        flag = this.Scope == null;
      return flag;
    }

    public bool Equals(
      CApExportToRTRStatusManager.IApExportToRTRIssueObject other)
    {
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString other1 = other as CApExportToRTRStatusManager.CApExportToRTRIssueObjectString;
      return (object) other1 != null && this.Equals(other1);
    }

    public override int GetHashCode() => this.Scope != null ? this.Scope.GetHashCode() : 0;

    public static bool operator ==(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString first,
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString second)
    {
      return (object) first != null ? first.Equals(second) : (object) second == null;
    }

    public static bool operator !=(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString first,
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString second)
    {
      return (object) first != null ? !first.Equals(second) : second != null;
    }

    public static bool operator ==(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString first,
      CApExportToRTRStatusManager.IApExportToRTRIssueObject second)
    {
      return (object) first != null ? first.Equals(second) : second == null;
    }

    public static bool operator !=(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectString first,
      CApExportToRTRStatusManager.IApExportToRTRIssueObject second)
    {
      return (object) first != null ? !first.Equals(second) : second != null;
    }
  }

  private class CApExportToRTRIssueObjectModel : 
    CApExportToRTRStatusManager.IApExportToRTRIssueObject,
    IEquatable<CApExportToRTRStatusManager.IApExportToRTRIssueObject>,
    IEquatable<CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel>
  {
    internal CApExportToRTRIssueObjectModel(ITxObject scope = null) => this.Scope = scope;

    internal ITxObject Scope { get; }

    public bool Equals(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel other)
    {
      return (object) other != null && this.Scope == other.Scope;
    }

    public override bool Equals(object obj)
    {
      bool flag = false;
      if (obj != null)
      {
        if (obj is ITxObject itxObject)
        {
          flag = this.Scope == itxObject;
        }
        else
        {
          CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel other = obj as CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel;
          if (other != (CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel) null)
            flag = this.Equals(other);
        }
      }
      else
        flag = this.Scope == null;
      return flag;
    }

    public bool Equals(
      CApExportToRTRStatusManager.IApExportToRTRIssueObject other)
    {
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel other1 = other as CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel;
      return (object) other1 != null && this.Equals(other1);
    }

    public override int GetHashCode() => this.Scope != null ? this.Scope.GetHashCode() : 0;

    public static bool operator ==(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel first,
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel second)
    {
      return (object) first != null ? first.Equals(second) : (object) second == null;
    }

    public static bool operator !=(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel first,
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel second)
    {
      return (object) first != null ? !first.Equals(second) : second != null;
    }

    public static bool operator ==(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel first,
      CApExportToRTRStatusManager.IApExportToRTRIssueObject second)
    {
      return (object) first != null ? first.Equals(second) : second == null;
    }

    public static bool operator !=(
      CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel first,
      CApExportToRTRStatusManager.IApExportToRTRIssueObject second)
    {
      return (object) first != null ? !first.Equals(second) : second != null;
    }
  }

  private class CApExportToRTRStatusSevirityScopeData
  {
    private CApExportToRTRStatusManager.CApExportToRTRStatusSevirityCounter m_severityCounter = new CApExportToRTRStatusManager.CApExportToRTRStatusSevirityCounter();
    private Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, int> m_objOfScopeIssueCount = new Dictionary<CApExportToRTRStatusManager.IApExportToRTRIssueObject, int>();

    internal Dictionary<CApExportToRTRStatusManager.IssueType, int> IssueTypeToNumberOfObjects { get; } = new Dictionary<CApExportToRTRStatusManager.IssueType, int>();

    internal CApExportToRTRStatusManager.Severity CurrentSeverity
    {
      get => this.m_severityCounter.WorstSeverity;
    }

    internal void AddIssueForObjOfScope(
      CApExportToRTRStatusManager.IApExportToRTRIssueObject objOfScope,
      CApExportToRTRStatusManager.IssueType issueType,
      CApExportToRTRStatusManager.Severity issueSeverity)
    {
      if (!this.m_objOfScopeIssueCount.ContainsKey(objOfScope))
        this.m_objOfScopeIssueCount.Add(objOfScope, 1);
      else
        this.m_objOfScopeIssueCount[objOfScope]++;
      if (!this.IssueTypeToNumberOfObjects.ContainsKey(issueType))
        this.IssueTypeToNumberOfObjects.Add(issueType, 1);
      else
        this.IssueTypeToNumberOfObjects[issueType]++;
      this.m_severityCounter.IncrementSeverity(issueSeverity);
    }

    internal void RemoveIssueForObjOfScope(
      CApExportToRTRStatusManager.IApExportToRTRIssueObject objOfScope,
      CApExportToRTRStatusManager.IssueType issueType,
      CApExportToRTRStatusManager.Severity issueSeverity)
    {
      int num;
      if (!this.m_objOfScopeIssueCount.TryGetValue(objOfScope, out num) || !this.IssueTypeToNumberOfObjects.ContainsKey(issueType))
        return;
      this.m_severityCounter.DecrementSeverity(issueSeverity);
      this.IssueTypeToNumberOfObjects[issueType]--;
      if (this.IssueTypeToNumberOfObjects[issueType] == 0)
        this.IssueTypeToNumberOfObjects.Remove(issueType);
      if (num == 1)
        this.m_objOfScopeIssueCount.Remove(objOfScope);
      else
        this.m_objOfScopeIssueCount[objOfScope]--;
    }

    internal bool IsEmptyScope() => this.IssueTypeToNumberOfObjects.Count == 0;

    internal bool IsObjOfScope(ITxObject obj)
    {
      return this.m_objOfScopeIssueCount.ContainsKey((CApExportToRTRStatusManager.IApExportToRTRIssueObject) new CApExportToRTRStatusManager.CApExportToRTRIssueObjectModel(obj));
    }
  }
}
